﻿using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;

namespace GameName1
{
    class AngryAlienExplosion : GameObject, IDisplayable, IMovable
    {
        private double _createdTime;
        private double _destructionDelay = 250;

        public AngryAlienExplosion(Vector2 position, GameTime gameTime) : base(position)
        {
            _createdTime = gameTime.TotalGameTime.TotalMilliseconds;          
        }

        public override void Update(GameTime gameTime)
        {
            if (gameTime.TotalGameTime.TotalMilliseconds > _createdTime + _destructionDelay)
            {
                GameObjectsManager.GetInstance().Destroy(this);
            }
        }
        public static void LoadContent(ContentManager contentManager)
        {
            _commonSprite = contentManager.Load<Texture2D>("sprites/explosion_v2");
        }

        private static Texture2D _commonSprite; 
        private Texture2D Sprite { get { return _commonSprite; } }
        public int DrawingOrder { get { return 0; } }
        public void Draw(SpriteBatch spriteBatch)
        {
            spriteBatch.Draw(Sprite, Position, Color.White);
        }
        
        public Vector2 Velocity { get; set; }
        public void Move()
        {
            AngryAlien.AngryAlienState.Move(this);
        }
    }
}
